import shutil
import random
from pathlib import Path

list1 = [chr(i) for  i in range(97, 123)]


p = Path('a/b/c/d/')
p.mkdir(parents=True, exist_ok=True)
p = Path('a/b/c/d/')/ 'e'

a = []
for x in range(10):
    for i in range(len(p.parents ) - 1 ):  
        a.append(i)
        b = random.choice(a)
        c = p.parents[b] / Path(''.join(random.choices(list1, k=4)))
        c.touch(exist_ok=True)
        print(c)




def  fn(x, y):
    ignore_names = set()
    print(x,type(x), y, type(y))
    for name in y:
        if  not( name.startswith('x') or name.startswith('y') or name.startswith('z')) and not (x / Path(name)).is_dir():
            ignore_names.add(name)
        print(ignore_names)
    return ignore_names


shutil.copytree('a', '43', ignore=fn)

# for x in range(10): 可以封装城函数
